package com.mp.approvalreq.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mp.approvalreq.entity.*;
import com.mp.approvalreq.entity.po.ComponentGroup;
import com.mp.approvalreq.entity.vo.Component;
import com.mp.approvalreq.service.ReadTemplateServicePrx;
import com.mp.comment.entity.Comment;
import com.mp.user.entity.User;
import com.mp.user.entity.dto.DepartmentDTO;
import com.mp.user.service.DepartmentServicePrx;
import com.plusmoney.util.DateTimeHelper;
import com.plusmoney.util.HTTPUtils;
import com.plusmoney.util.Utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import static java.util.Comparator.*;

/**
 * 抽出导出审批共有的属性和行为
 */
public class ExportTemplate {
    private static final Logger logger = LoggerFactory.getLogger(ExportTemplate.class);
    final ExcelParam excelParam;

    ExportTemplate(ExcelParam excelParam) {
        this.excelParam = excelParam;
        initSimpleDateFormat();
    }

    // 标题行样式、月份行样式、左对齐样式、居中样式
    // 实际上,应该写成getter/setter(),然后做Init校验
    CellStyle headStyle;
    CellStyle leftDataStyle;
    CellStyle centerDataStyle;

    void initCellStyle(HSSFWorkbook wb) {
        headStyle = getHeadStyle(wb);
        leftDataStyle = getLeftCenterStyle(wb);
        centerDataStyle = getCenterAlignStyle(wb);
    }

    // 获取标题行样式
    private static CellStyle getHeadStyle(HSSFWorkbook wb) {
        Font headFont = ExcelUtil.createFont(wb, "微软雅黑", 16, false);
        CellStyle headRowStyle = ExcelUtil.createCellStyle(wb, 1, 1, 1, 1);
        headRowStyle.setFont(headFont);
        return headRowStyle;
    }

    // 获取单元格内容左对齐样式
    private static CellStyle getLeftCenterStyle(HSSFWorkbook wb) {

        Font itemFont = ExcelUtil.createFont(wb, "微软雅黑", 14, false);
        CellStyle leftDataStyle = ExcelUtil.createCommentLEFTStyle(wb, 1, 1, 1, 1);
        leftDataStyle.setFont(itemFont);
        return leftDataStyle;
    }

    // 获取单元格内容居中对齐样式
    private CellStyle getCenterAlignStyle(HSSFWorkbook wb) {
        Font itemFont = ExcelUtil.createFont(wb, "微软雅黑", 14, false);
        CellStyle centerDataRowStyle = ExcelUtil.createCellStyle(wb, 1, 1, 1, 1);
        centerDataRowStyle.setFont(itemFont);
        return centerDataRowStyle;
    }

    private SimpleDateFormat hmSDF;

    private SimpleDateFormat chineseHMSDF;
    private SimpleDateFormat ymdSDF;
    private SimpleDateFormat ymdCHSDF;
    private boolean SDFFlag = false;

    private void initSimpleDateFormat() {
        hmSDF = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        chineseHMSDF = new SimpleDateFormat("yyyy-MM-dd E HH:mm", Locale.CHINESE);
        ymdSDF = new SimpleDateFormat("yyyy-MM-dd");
        ymdCHSDF = new SimpleDateFormat("yyyy年M月d日");
        SDFFlag = true;
    }

    private boolean isInitSimpleDateFormat() {
        return SDFFlag;
    }

    // 组件Num,组件type
    List<Integer> numList;
    List<Integer> typeList;

    void autoSizeOfSheetCell(HSSFSheet sheet) throws Throwable {
        Map<Integer, String> map = new HashMap<>();
        int maxCellIndex = getMaxSizeInSheet(sheet, map);
        Row maxRow = sheet.getRow(maxCellIndex);
        for (int index = 2; index <= maxRow.getPhysicalNumberOfCells(); index++) {     // 忽略第一列时间格式的宽度,前面已设置(固定)
            if (map.get(index) == null) {
                continue;
            }
            int colWidth = Integer.parseInt(map.get(index).substring(0, map.get(index).length() - 2));
            sheet.setColumnWidth(index, Math.min(colWidth, 12300));    // 限制最大长度为12300,因为单个单元格的宽度不能超过255个字符,这里的12290是测试看起来顺眼的,没有其他的意义
        }
    }

    private int getMaxSizeInSheet(HSSFSheet sheet, Map<Integer, String> map) {       // sheet,最后一行
        int columnSize = 0;        // 保存列数
        int maxCellIndex = 0;    // 保存有最多列数的行num
        for (int i = 7; i <= sheet.getLastRowNum(); i++) {        // 行的计数从7开始,忽略掉表头
            Row row = sheet.getRow(i);    // 第i行
            if (row == null) {
                continue;
            }

            if (columnSize < row.getPhysicalNumberOfCells()) {
                columnSize = row.getPhysicalNumberOfCells();
                maxCellIndex = i;
            }

            for (int j = 1; j <= row.getPhysicalNumberOfCells(); j++) {    // 遍历该行的列数,列的计数从1开始,,这里从2计数是为了忽视掉：2017年7月 这样的表格头行
                Cell test = row.getCell(j);
                if (test == null) {
                    continue;
                }

                String value = null;
                if (test.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {         // 单元格类型为数值
                    value = test.getNumericCellValue() + "";
                } else if (test.getCellType() == HSSFCell.CELL_TYPE_STRING) {
                    value = test.getStringCellValue().trim();
                }

                if (value == null) {
                    continue;
                }
                //
                double valueLength = getValueLength(value);

                /* 时间日期格式,设置为固定的 */
                valueLength = getDateValueLength(value, valueLength);

                if (map.containsKey(j)) {
                    if (Double.parseDouble(map.get(j)) < valueLength) {  // 本次的列长度大于map的保存的长度,则替换
                        map.put(j, Math.ceil(valueLength) + "");
                    }
                } else {
                    map.put(j, Math.ceil(valueLength) + "");
                }
            }
        }

        return maxCellIndex;
    }

    private double getValueLength(String value) {
        double tempLength = 0;
        if (value.contains("\n")) {                    // 用于辨别出最长的那条评论或关联客户,以它作为该单元格的宽度
            String[] lenArray = value.split("\n");
            int maxLen = 0;
            for (String s : lenArray) {
                if (s.getBytes().length > maxLen) {
                    maxLen = s.getBytes().length;
                }
            }
            tempLength = maxLen * 256;
        } else {
            tempLength = value.getBytes().length * 300;
        }

        if (value.equals("参与人") || value.equals("抄送人")) {
            logger.info("value:{}, 长度:{}", value, tempLength);
        }

        return tempLength;
    }

    private double getDateValueLength(String value, double valueLength) {
        double tempLength = valueLength;

        if (value.length() == 19) {
            String tempValue = value.substring(0, 10);       // 2017-09-22 周六 22:04 --> 2017-09-22
            if (ValidateUtil.isValidDate(tempValue)) {
                tempLength = 7726.0;
            }
        } else if (ValidateUtil.isValidDate(value)) {        // 2017-09-22
            tempLength = 4120;
        } else if (ValidateUtil.isValidDateTime(value)) {   // 2017-09-22 22:04
            tempLength = 6557;
        }

        return tempLength;
    }

    // 导出范围: 2018年3月10日-2018年3月31日(共21日)
    String getExportScopeStrByDays(List<String> days) throws Throwable {
        String exportScopeStr = "";
        exportScopeStr += changeChDay(days.get(0));
        if (days.size() > 1) {
            exportScopeStr += "-" + changeChDay(days.get(days.size() - 1));
            exportScopeStr += "（共" + countDays(days.get(0), days.get(1)) + "日）";
        }
        return exportScopeStr;
    }

    // 计算时间
    private long countDays(String startDay, String endDay) throws Throwable {
        if (!isInitSimpleDateFormat()) {
            initSimpleDateFormat();
        }
        long startTime = ymdSDF.parse(startDay).getTime();
        long endTime = ymdSDF.parse(endDay).getTime();
        return (endTime - startTime) / (1000 * 60 * 60 * 24) + 1;
    }

    // yyyy-MM-dd --> yyyy年M月d日
    private String changeChDay(String day) throws ParseException {
        if (!isInitSimpleDateFormat()) {
            initSimpleDateFormat();
        }
        return ymdCHSDF.format(ymdSDF.parse(day).getTime());
    }

    // 设置无网格线
    void setNoGridLines(HSSFSheet sheet) {
        sheet.setDisplayGridlines(false);       // 无网格线
        sheet.setPrintGridlines(false);
        sheet.setFitToPage(true);
        sheet.getPrintSetup().setLandscape(false);
    }

    /**
     * 发送邮件
     * 参数:
     * emails --- 邮箱
     * emailContent:文本内容
     * emailFileList: 附件
     */
    void sendEmail(String emailContent, List<File> emailFileList) throws Throwable {
        List<String> emails = excelParam.getEmails();
        String emailTitle = "大管加审批记录导出";
        for (String email : emails) {
            ExcelUtil.sendQQMail(email, emailTitle, emailContent, emailFileList);
        }
    }

    // 保存一份文件至服务器
    List<File> getFileList(HSSFWorkbook wb, StringBuilder templateNames) throws Throwable {
        User user = excelParam.getUser();
        String exportPath = excelParam.getExportPath();

        File export = new File(exportPath);
        if (!export.exists()) {
            export.mkdir();
        }
        String[] names = templateNames.toString().split("、");
        StringBuilder fileName = new StringBuilder();
        for (int i = 0; i < names.length; i++) {
            fileName.append(names[i]).append("、");
            if (i == 2) {                               // 超出三个,取三个模板名即可
                fileName.deleteCharAt(fileName.length() - 1);
                fileName.append("...");
                break;
            }
        }
        if (fileName.toString().endsWith("、")) {
            fileName.deleteCharAt(fileName.length() - 1);
        }
        logger.info("文件名: " + fileName);
        String name = CheckUtil.replaceNonlicetFilePathCharacter(fileName.toString());
        String filePath = exportPath + "/" + user.getCompanyName() + "-" + name + "_" + UUID.randomUUID() + ".xls";
        File file = new File(filePath);
        if (!file.exists()) {
            file.createNewFile();
        }
        wb.write(file);
        wb.close();
        List<File> fileList = new ArrayList<>();
        fileList.add(file);
        return fileList;
    }

    // 合并标题单元格
    // 参数:lastHeaderRowIndex --> 第一个模板标题所在行
    void mergeHeaderRegion(HSSFSheet sheet, int lastHeaderRowIndex) {
        try {
            int lastColIndex = sheet.getRow(lastHeaderRowIndex + 2).getLastCellNum() - 1;
            for (int rowIndex = 1; rowIndex <= lastHeaderRowIndex; rowIndex++) {
                int topBorder = 0;
                int downBorder = 0;
                if (rowIndex == 1) {
                    topBorder = 1;
                    downBorder = 0;
                } else if (rowIndex == lastHeaderRowIndex) {
                    downBorder = 1;
                }
                ExcelUtil.createRegion(sheet, rowIndex, rowIndex, 1, lastColIndex, topBorder, downBorder, 1, 1);
            }
        } catch (Throwable e) {
            logger.error("行:{}", lastHeaderRowIndex + 2);
            logger.error(e.getMessage(), e);
        }
    }

    private static final String CRM_CUSTOMER_URL = "https://www.erplus.co/api/v1/crm/customers/";
    private static final String URL_SUFFIX = "/customerInfo";

    //如果为关联客户,先调用德伟接口获取客户id,再写一个dao获取客户名
    String getClientTypeValue(int ancestorId) throws Exception {
        StringBuilder value = new StringBuilder("");
        List<Customer> customerList = getRelateCustomer(ancestorId);    //获取关联客户id
        if (ListHelper.isNullEmpty(customerList)) {
            return value.toString();
        }

        String customerIds = getCustomerIds(customerList);
        logger.info("url:{}", CRM_CUSTOMER_URL + customerIds + URL_SUFFIX);
        String result = HTTPUtils.get(CRM_CUSTOMER_URL + customerIds + URL_SUFFIX, excelParam.getAtoken());
        logger.info("获取信息:{}", result);

        setCustomerNames(customerList, result);

        for (int a = 0; a < customerList.size(); a++) {
            Customer cus = customerList.get(a);
            value.append((cus.getName() == null ? "" : cus.getName()));
            if (customerList.size() - a > 1 && cus.getName() != null) {
                value.append("\n");
            }
        }
        return value.toString();
    }

    private void setCustomerNames(List<Customer> customerList, String result) {
        if (StringUtils.isEmpty(result)) {
            return;
        }
        JSONObject jsonObject = JSON.parseObject(result);
        JSONArray arr = jsonObject.getJSONArray("item");
        for (int i = 0; i < arr.size(); i++) {
            JSONObject object = arr.getJSONObject(i);
            String name = object.getString("name");
            String id = object.getString("id");
            logger.info("id:{}, name:{}", id, name);

            for (Customer customer : customerList) {
                if (Objects.equals(id, customer.getObjectIdB())) {
                    customer.setName(name);
                    break;
                }
            }
        }
    }

    private String getCustomerIds(List<Customer> customerList) {
        List<String> customerIds = new ArrayList<>(customerList.size());

        for (Customer customer : customerList) {
            customerIds.add(customer.getObjectIdB());
        }

        return ListHelper.list2string(customerIds);
    }

    protected enum RequestFlag {
        /**
         * 审批人、抄送人、临时抄送人、参与人、归档人、批准时间、评论、申请人、请假时长、审批状态
         */
        JUDGER, CC, CC_TEMP, RELA_PEOPLE, ARCHIVER, CONFIRM_TIME, COMMENT, APPLICANT, LEAVE_DURATION, APPROVAL_STATUS
    }

    boolean isApplicant(RequestFlag flag) {
        return flag.equals(RequestFlag.APPLICANT);
    }

    boolean isPerson(RequestFlag flag) {
        boolean mark = false;
        switch (flag) {
            case CONFIRM_TIME:
            case LEAVE_DURATION:
            case COMMENT:
            case APPROVAL_STATUS:
                break;
            default:
                // 除批准时间、审批评论
                mark = true;
        }
        return mark;
    }

    // 14为关联客户,2为多行文本,6为外出地点
    boolean isLeftDataStyle(int offset) {
        boolean flag = false;
        switch (typeList.get(offset)) {
            case CLIENT_TYPE:
            case MORETEXT:
            case SITE_TYPE:
                flag = true;
                break;
            default:
                break;
        }
        return flag;
    }

    private List<Customer> getRelateCustomer(int objectIdB) throws Exception {
        int type = 1;
        String param = "objectId=" + objectIdB + "&type=" + type;
        String url = "https://www.erplus.co/taskWeb/getProjectRelate" + "?" + param;
        String result = HTTPUtils.get(url, excelParam.getAtoken());
        logger.info("获取客户url:" + url + param);
        logger.info("获取后的数据：" + result);

        JSONObject rejo = JSONObject.parseObject(result);
        List<Customer> customerList = JSONObject.parseArray(rejo.getString("item"), Customer.class);
        if (ListHelper.isNullEmpty(customerList)) {
            return customerList;
        }

        List<Customer> list = new ArrayList<>();
        for (Customer customer : customerList) {
            // 2- 客户; 10-供应商
            if (customer.getTypeB() == 2 || customer.getTypeB() == 11) {
                list.add(customer);
            }
        }
        return list;
    }

    String getMoreSelectValue(String comValue) {
        return comValue.replace("[", "").replace("]", "").replaceAll("\"", "");
    }

    String getSiteTypeValue(String comValue) {
        StringBuilder value = new StringBuilder("");
        String temp = comValue.replace("[", "").replace("]", "").replaceAll("\"", "");
        if (temp.contains(",")) {
            String[] outValue = temp.split(",");
            for (int j = 0; j < outValue.length; j++) {
                value.append("目的地").append(j + 1).append(" : ").append(outValue[j]);
                if (outValue.length - j > 1) {
                    value.append("\n");
                }
            }
        } else {
            value.append("目的地 : ").append(temp);
        }
        return value.toString();
    }

    // 获取每个模板的组件
    List<TemplateComponent> getComponentList(Template template) {
        List<TemplateComponent> comList = JSONObject.parseArray(template.getTemplateComponent(), TemplateComponent.class);
        comList.sort(comparingInt(TemplateComponent::getNum));
        return comList;
    }

    // 消除内容最前面的换行和最后面的换行
    String removeNewLine(String value) {
        String tempValue = value;
        if (StringUtils.isEmpty(tempValue)) {
            return value;
        }

        while (tempValue.startsWith("\n")) {
            tempValue = tempValue.substring(1);
        }

        while (tempValue.endsWith("\n")) {
            tempValue = tempValue.substring(0, tempValue.length() - 1);
        }

        return tempValue;
    }

    String getPrintContent(Request req, RequestFlag flag) throws Throwable {
        String content = "";
        switch (flag) {
            case JUDGER:
                content = req.getAllJudger();
                break;
            case CC:
                content = req.getCc();
                break;
            case CC_TEMP:
                content = req.getCcTemp();
                break;
            case RELA_PEOPLE:
                content = req.getRelaPeople();
                break;
            case ARCHIVER:
                content = req.getArchived();
                break;
            case APPROVAL_STATUS:
                switch (req.getFinished()) {
                    case Finished.AGREED:
                        content = "已批准";
                        break;
                    case Finished.REFUSED:
                        content = "已驳回";
                        break;
                    case Finished.CALLING_BACK:
                        content = "已撤销";
                        break;
                    case Finished.CANCELLED:
                        content = "已作废";
                        break;
                    case Finished.ARCHIVED:
                        content = "已归档";
                        break;
                    case Finished.APPROVING:
                        content = "待批准";
                        break;
                    default:
                        content = "-";
                        break;
                }
                break;
            case CONFIRM_TIME:
                content = req.getLatestApprovedTime();
                break;
            case COMMENT:
                content = getComment(req);
                break;
            case APPLICANT:
                content = String.valueOf(req.getApplicant());
                break;
            case LEAVE_DURATION:
                content = req.getNaturalContentTimeLast();
                break;
            default:
                break;
        }
        return content;
    }

    // 获取审批评论
    private String getComment(Request req) throws Throwable {
        ReadTemplateServicePrx rts = excelParam.getReadService();
        User user = excelParam.getUser();
        StringBuilder sb = new StringBuilder("");
        List<Comment> list = rts.getCommentMessage(req, user);            // 获取评论
        if (!ListHelper.isNullEmpty(list)) {
            for (int j = 0; j < list.size(); j++) {
                Comment com = list.get(j);
                sb.append(com.getCrtName()).append(":").append(com.getMsg());
                if (list.size() - j > 1) {
                    sb.append("\n");
                }
            }
        }
        return sb.toString();
    }

    String getApplicantName(String contactId) {
        String name;
        People people = contactMap.get(Integer.valueOf(contactId));
        if (Utils.isNull(people)) {
            return "查无此人";
        }

        if (StringUtils.isNotEmpty(people.getDeptName())) {
            name = people.getName() + "(" + people.getDeptName() + ")";
        } else {
            name = people.getName();
        }

        if (people.getDeleteTime() != null) {
            name += "（已离职）";
        }

        return name;
    }

    String getContactsName(String idsStr) {
        if (idsStr == null || idsStr.equals("")) {
            return "";
        }
        StringBuilder result = new StringBuilder("");
        for (String idStr : idsStr.split(",")) {
            int id = Integer.parseInt(idStr);
            result.append(getContactName(contactMap.get(id))).append(",");
        }
        if (result.length() > 0) {
            result.deleteCharAt(result.length() - 1);
        }
        return result.toString();
    }

    private String getContactName(People people) {
        if (people == null || people.getName() == null) {
            return "查无此人";
        }
        if (people.getDeleteTime() != null) {
            return people.getName() + "（已离职）";
        }
        return people.getName();
    }

    String changeCHTime(String fromTime) throws ParseException {
        if (!isInitSimpleDateFormat()) {
            initSimpleDateFormat();
        }
        if (StringUtils.isEmpty(fromTime)) {
            return "";
        }
        String toTime = chineseHMSDF.format(hmSDF.parse(fromTime));
        return toTime.replaceAll("星期", "周").replaceAll("天", "日");
    }

    String changeCHTimeV2(String fromTime) throws ParseException {
        if (!isInitSimpleDateFormat()) {
            initSimpleDateFormat();
        }
        if (StringUtils.isEmpty(fromTime)) {
            return "";
        }

        String toTime = chineseHMSDF.format(DateTimeHelper.parse(fromTime));
        return toTime.replaceAll("星期", "周").replaceAll("天", "日");
    }

    void shiftTemplateComponents(List<TemplateComponent> comList) {
        numList = new ArrayList<>();                                //    组件的num: 决定位置
        typeList = new ArrayList<>();                            //    组件的type: 类型
        for (TemplateComponent temp : comList) {
            if (temp.getType() > 7 && temp.getType() < 12) {    //模板组件中： 8：相关任务，9：相关外出，10：相关申购，11：相关附件,这些信息要排除出去
                continue;
            } else if (temp.getType() == 16) {                // 把这个 [新增一条打卡、目的地之类的 ]去掉
                continue;
            } else if (temp.getType() == 6 && temp.getNeed() == 2 && temp.getNum() == 5) {
                continue;
            }
            logger.info("组件位置:" + temp.getNum() + " 组件类型:" + temp.getType() + " 组件名字:" + temp.getName());
            numList.add(temp.getNum());
            typeList.add(temp.getType());
        }
    }

    Map<Integer, List<Integer>> subNumMap = new HashMap<>();

    Map<Integer, List<Integer>> subTypeMap = new HashMap<>();

    /**
     * 组件集里面也要排除掉无需打印的组件
     *
     * @param groups
     */
    List<ComponentGroup> shiftComponentGroup(List<ComponentGroup> groups) {
        for (ComponentGroup group : groups) {
            List<Component> components = new ArrayList<>();

            List<Integer> subNums = new ArrayList<>();
            List<Integer> subTypes = new ArrayList<>();

            for (Component component : group.getComponents()) {
                if (component.getType() > 7 && component.getType() < 12) {
                    continue;
                }
                components.add(component);
                subNums.add(component.getNum());
                subTypes.add(component.getType());
            }

            subNumMap.put(group.getNum(), subNums);
            subTypeMap.put(group.getNum(), subTypes);

            components.sort(comparingInt(Component::getNum));
            group.setComponents(components);
        }

        return groups;
    }

    // 该公司<contactId, people>的Map
    private Map<Integer, People> contactMap;

    void convertUserToPeople(List<User> userList) {
        contactMap = new HashMap<>();
        for (User user : userList) {
            People people = new People();
            people.initPeople();
            people.setContactId(user.getContactId());
            people.setName(user.getContactName());
            people.setDeptId(user.getDeptId() == null ? 0 : user.getDeptId());
            if (user.getQuit()) {
                people.setDeleteTime("已离职");   // 随意设置一个离职标记,用于方法判断给员工离职
            }
            contactMap.put(user.getContactId(), people);
        }
        wrapAllUserDeptName(excelParam.getUser().getCompanyId());
    }

    private void wrapAllUserDeptName(Integer companyId) {
        DepartmentServicePrx departmentService = ServiceUtils.getDepartmentServicePrx();
        try {
            List<DepartmentDTO> departmentDTOs = departmentService.getAllDepartmentList(companyId);
            for (People people : contactMap.values()) {
                for (DepartmentDTO departmentDTO : departmentDTOs) {
                    if (Objects.equals(people.getDeptId(), departmentDTO.getId())) {
                        people.setDeptName(departmentDTO.getName());
                        break;
                    }
                }
            }
        } catch (Throwable throwable) {
            logger.error(throwable.getMessage(), throwable);
        }
    }

    //		公司名 ：西木由视众传媒与文化有限公司
//		审批类型 ：高级外出、请假、灵活审批流测试
//		导出范围 ：2018年3月10日-2018年3月31日(共21日)
//		导出时间 ：2017-08-26 11:25
//		导出人 ：洛夕佑
    String getEmailContentByDays(String templateName) throws Throwable {
        User user = excelParam.getUser();
        List<String> days = excelParam.getDays();
        return "" + "公司名 :" + user.getCompanyName() + "<br>"
                + "审批类型 :" + templateName + "<br>"
                + "导出范围 :" + getExportScopeStrByDays(days) + "<br>"
                + "导出时间 :" + excelParam.getExportTime() + "<br>"
                + "导出人 :" + user.getContactName();
    }

    private static final int MORETEXT = 2;
    protected static final int DATE_TYPE = 4;
    static final int TIME_TYPE = 5;
    static final int SITE_TYPE = 6;
    static final int MORE_SELECT = 12;
    static final int MONEY_TYPE = 13;
    static final int CLIENT_TYPE = 14;

    static final int ATTENDANCE_TYPE = 15;
    /**
     * 补卡班次
     */
    static final int RECEIVE_CLOCK_TICK = 21;
    /**
     * 补卡类型 0.签到;1.签退;2.上午签到;3.上午签退;4.下午签到;5.下午签退
     */
    static final int RECEIVE_CLOCK_TYPE = 22;
    /**
     * 补卡时段
     */
    static final int RECEIVE_CLOCK_TIME = 23;
    /**
     * 组件集
     */
    protected static final int COMPONENT_GROUP = 24;

    // 已打印组件集数量
    int lastOffset = 0;
}
